VSCode 中使用typescript檢視output - Code Runner套件


Posted by mijouhsieh on 2024-01-01

tsc hello.ts

指令意思是,用 typescript compiler 去執行TypeScript的編譯器,編譯hello.ts 檔案,會 產生 hello.js檔案

// hello.ts
// 相減函式
function subtract (num1:number, num2: number) {
  return num1-num2
}
const total = subtract(5,3)
console.log(total)
// hello.js
// 相減函式
function subtract(num1, num2) {
    return num1 - num2;
}
const total = subtract(5, 3);
console.log(total);

Q: 要在哪邊才看到 console.log(total)的輸出結果?

1 安裝VSCode套件

vscode-extension-code-runner.png

2 在js檔 右鍵Run Code快捷鍵: ctrl+alt+n 或 右上角三角形按鈕

就會出現OUTPUT,console結果會在[Running]區塊

vscode-extension-run-code.png


#code runner #VSCode extension







Related Posts

BootStrap5 第二章 - 排版(格線系統 )

BootStrap5 第二章 - 排版(格線系統 )

Cyberpunk 風格按鈕動畫

Cyberpunk 風格按鈕動畫

C 語言練習程式(7) -- 直接改變陣列內容&利用指標達成回傳型態轉換 -- 指標相關程式集錦(6)

C 語言練習程式(7) -- 直接改變陣列內容&利用指標達成回傳型態轉換 -- 指標相關程式集錦(6)


Comments